/*
A Changer
control_B
title_B
trigger_B
score_B
cap_active_B
zone_B



*/


while {true} do {
sleep dure_cap;


//////////////////// ACTIF //////////////////////////////////////////////////////////////
if ((control_A == 1) && (control_C == -1))  then { // Zone A ATT et Zone C DEF
cap_active_B = true;
_type = getMarkerType "title_B"; if (_type != "selector_selectedMission") then {"title_B" setMarkerType "selector_selectedMission"};
};
////////////////////////////////////////////////////////////////////////////////////////

//////////////////// BLOQUER //////////////////////////////////////////////////////////
if ((control_A == 0) or (control_C == 0)) then { // Zone A ou C neutre
cap_active_B = false;
_type = getMarkerType "title_B"; if (_type != "selector_selectable") then {"title_B" setMarkerType "selector_selectable"};
};
////////////////////////////////////////////////////////////////////////////////////////

//////////////////// VERROUILLER ///////////////////////////////////////////////////////
if ((control_A == -1) && (control_B == -1))  then { // A et B DEF => verrouiller par DEF
cap_active_B = false;
score_B = -100;
_color = getMarkerColor "zone_B"; if (_color != "ColorRed") then {"zone_B" setMarkerColor "colorRed"};
_color = getMarkerColor "title_B"; if (_color != "ColorRed") then {"title_B" setMarkerColor "colorRed"};
_type = getMarkerType "title_B"; if (_type != "mil_box") then {"title_B" setMarkerType "mil_box"};
};

if ((control_B == 1) && (control_C == 1))  then { // B et C ATT => verrouiller par ATT
cap_active_B = false;
score_B = 100;
_color = getMarkerColor "zone_B"; if (_color != "ColorBlue") then {"zone_B" setMarkerColor "colorBlue"};
_color = getMarkerColor "title_B"; if (_color != "ColorBlue") then {"title_B" setMarkerColor "colorBlue"};
_type = getMarkerType "title_B"; if (_type != "mil_box") then {"title_B" setMarkerType "mil_box"};
};
////////////////////////////////////////////////////////////////////////////////////////




//////////////////// Script Cap /////////////////////////////////////////////////////////////
if (cap_active_B) then {

	// Qui controle ?
	
	// Zone Neutre
	if (control_B == 0) then {
		if (score_B == 100) then {control_B = 1; "title_B" setMarkerColor "ColorBlue"}; // zone cap par Att
		if (score_B == -100) then {control_B = -1; "title_B" setMarkerColor "ColorRed"}; // zone cap par Def
	};
	
	// Zone capé
	if ((control_B == 1) && (score_B <= 0)) then {control_B = 0; "title_B" setMarkerColor "ColorBlack"}; // zone perdu par ATT, devient neutre
	if ((control_B == -1) && (score_B >= 0)) then {control_B = 0; "title_B" setMarkerColor "ColorBlack"}; // zone perdu par DEF, devient neutre
	

	
	// CAP
	
	// Att > Def
	if (score_B < 100) then {
		if ((att_side countside list trigger_B) > (def_side countside list trigger_B)) then {
			_nb_att = ((att_side countside list trigger_B) - (def_side countside list trigger_B));
			score_B = score_B + _nb_att;
			if (score_B > 100) then {score_B = 100}; // on ne dépasse pas 100
		};
	};
	
	// Def > Att
	if (score_B > -100) then {
		if ((def_side countside list trigger_B) > (att_side countside list trigger_B)) then {
			_nb_def = ((def_side countside list trigger_B) - (att_side countside list trigger_B));
			score_B = score_B - _nb_def;
			if (score_B < -100) then {score_B = -100}; // on ne dépasse pas -100
		};
	};
	
	
	
	// Couleur markeur 
	if (score_B < 0) then {  // zone cap par DEF
		_alpha = score_B / -200;  
		"zone_B" setMarkerAlpha _alpha; 
		"zone_B" setMarkerColor "ColorRed"
	};
			
	if (score_B > 0) then {  // zone cap par ATT
		_alpha = score_B / 200;  
		"zone_B" setMarkerAlpha _alpha; 
		"zone_B" setMarkerColor "ColorBlue"
	};
	
	if (score_B == 0) then {  // Neutre invisible.
	"zone_B" setMarkerAlpha 0;
	"title_B" setMarkerColor "ColorBlack";
	};

	
}; 


};